package com.chaofan.domain;

/**
 * @author 李超凡
 * @since 2022/1/12 22:11
 */
public class R<T> {

    private String code;

    private String message;

    private T data;

    public static R<String> success() {
        return new R<>(null);
    }

    public static R<String> success(String data) {
        return new R<>(data);
    }

    public static R<String> fail() {
        return new R<>("1", "fail");
    }

    public static R<String> fail(String code, String msg) {
        return new R<>(code, msg);
    }

    public R(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public R(T data) {
        code = "0";
        message = "success";
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
